<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        function Grand(){};
        function Parent(){};

        Grand.prototype.tskill="拉二胡";
        var grand=new Grand();
        // Parent.prototype=grand;
        var parent =new Parent();
        Parent.prototype.tskill="弹琴";
        console.log(parent.tskill);
        console.log(grand.tskill); 

        // 1.
    function Test(){
       this.name = name;
       this.age = age;
     }

// 分别使用call，apply为obj添加name，age属性
    obj={
        
    }
    // Test.apply(obj,name="xx",age=22)
    Test.call(obj,name="dd",age=19)
    console.log(obj);

//2. 实现陈鹏买车，其中有sayHi方法，功能:打印'陈鹏买了一辆红色的2.0宝马车'
    function sayHi(name,colour,cc,brand){
        this.name=name
        this.colour=colour
        this.cc=cc
        this.brand=brand
        console.log(name+"买了一辆"+colour+"的"+cc+brand);
        
    }
    sayHi("陈鹏","红色","2.0","宝马车")

    

// 3.父类Shape （属性有:name,length,width,方法有:Intro 我是XX形）

// 子类： Circle(属性有:r)

// 分别使用 原型链继承 构造函数继承 圣杯继承

//原型链
    function Shape(){
        function Intro(){
            console.log("我是xx形");
        }
    };
    function Circle(){};
    Shape.prototype.name="aa";
    Shape.prototype.length=3;
    Shape.prototype.width=3;
    var shape = new Shape();
    Circle.prototype=shape;
    var circle=new Circle();
    Circle.prototype.r=3
    console.log(circle);


//构造函数
    function Shape(name,length,width){
        this.name=name
        this.length=length
        this.width=width
        function Intro(){
            console.log("我是xx形");
        }
    };
    function Circle(r,name,length,width){
        Shape.call(this,name,length,width)
        this.r=r
    };
    var circle=new Circle("b","a",3,3);
    console.log(circle);

//圣杯模式
    function Shape(){
        function Intro(){
            console.log("我是xx形");
        }
    };
    function Circle(){};
    Shape.prototype.name="aa";
    Shape.prototype.length=3;
    Shape.prototype.width=3;

    function inherit(Target,Origin){
        function F() {
        }
        F.prototype=Origin.prototype;
        Target.prototype=new F();
        Target.prototype.constructor=Target;
        Target.prototype.uber=Origin;
    }
    inherit(Circle,Shape)
    var circle=new Circle();
    Circle.prototype.r=3
    console.log(circle);






   




    
    </script>
</body>
</html>